<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script>
			//冒泡排序
			var arr=[1,11,-1,0,20];
			var temp;
			function sort(arr){
				var flag = true;
				for(var i = 0; i<arr.length-1;i++){
					for(var j = 0;j<i;j++){
						if(arr[j] > arr[j+1]){
							flag=false;
							temp = arr[j];
							arr[j]=arr[j+1];
							arr[j+1]=temp;
						}
					}
				}
				return arr;
			}
			console.log(sort(arr));
	</script>
</body>
</html>
